package com;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

import com.func.*;

/**
 * @author yinmage
 * @date 2022/08/03
 */
public class Execute {
    public static List<Server> getServerList() {
        List<Server> list = new ArrayList<>();
        list.add(new Server("中杯", 1));
        list.add(new Server("大杯", 3));
        list.add(new Server("超大杯", 5));
        return list;
    }

    public static void executeRandom() {
        Random random = new Random();
        executeByRequest(random);
    }

    public static void executePolling() {
        Polling polling = new Polling();
        executeByRequest(polling);
    }

    public static void weightedRandom() {
        WeightedRandom weightedRandom = new WeightedRandom();
        executeByRequest(weightedRandom);
    }

    public static void weightedPolling() {
        WeightedPolling weightedPolling = new WeightedPolling();
        executeByRequest(weightedPolling);
    }

    public static void executeByRequest(Request request){
        Scanner scanner = new Scanner(System.in);
        System.out.println("任意键请求一次 0.退出");
        while (true) {
            String input = scanner.nextLine();
            if (input.equals("0")) {
                request.total();
                break;
            } else {
                request.doRequest();
            }
        }
    }
}
